package com.xmall.timer.controller;

import cn.hutool.json.JSONUtil;
import com.xmall.annotation.LoginRequiredFalse;
import com.xmall.define.base.Result;
import com.xmall.timer.service.ICommonRetryLogTaskService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 公共控制器
 */
@RequestMapping("/service/common/retryLogTask")
@RestController
public class CommonRetryLogTaskController {

    @Resource
    private ICommonRetryLogTaskService retryLogTaskService;

    /**
     * 任务列表
     */
    @LoginRequiredFalse
    @GetMapping("/taskList")
    public Result<String> taskList() {
        return Result.success(JSONUtil.toJsonStr(retryLogTaskService.taskList()));
    }

    /**
     * 重试日志分页列表
     */
    @LoginRequiredFalse
    @GetMapping("/logListPage")
    public Result<String> retryLogListPage(@RequestParam("page") Integer page,
                                           @RequestParam("pageSize") Integer pageSize,
                                           @RequestParam("key") String key) {
        return Result.success(JSONUtil.toJsonStr(retryLogTaskService.logListPage(page, pageSize, key)));
    }
}
